package com.exsun.ex1077.ui.activity.trackdetail

import androidx.databinding.ObservableField
import androidx.lifecycle.MutableLiveData
import com.alibaba.fastjson.JSONObject
import com.exsun.ex1077.network.apiService
import com.exsun.ex1077.network.entity.TrackDetail
import com.exsun.ex1077.network.entity.VehicleTrack
import com.zhangping.fastjetpack.base.BaseViewModel
import com.zhangping.fastjetpack.extend.base.ResultState
import com.zhangping.fastjetpack.extend.base.request

/**
 * 描述：
 * 作者：ZhangPing
 * 创建时间：2022/5/17 8:58
 */
class TrackDetailViewModel: BaseViewModel() {

    val model = ObservableField<VehicleTrack>()
    var vehicleNo = ""
    var objType = 0
    val trackDetailResult = MutableLiveData<ResultState<List<TrackDetail>?>>()

    fun loadData(){
        //请求轨迹数据
        request({ apiService.vehicleTrackDetail(JSONObject().apply {
            put("dvo", model.get()?.dvo)
            put("startTime", model.get()!!.beginTime)
            put("endTime", model.get()!!.endTime)
        })}, trackDetailResult, true)
    }
}